package com.dj.uphome.web.controller;

import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.alibaba.fastjson.JSONObject;
import com.dj.common.web.rest.ResponsePack;
import com.dj.common.web.rest.RestApiError;

/** 
 * 类名称：ErrorController
 * 创建人：何利荣
 * 创建时间：2017-05-28
 */
@Controller
public class ErrorController {
	
	 /**
	 * 错误500
	 */
	@RequestMapping(value = "/error_500", produces = { MediaType.APPLICATION_JSON_VALUE })
	public ResponseEntity<ResponsePack<JSONObject>> error_500(){
		RestApiError rae = new RestApiError();
		rae.setCode("500");
		rae.setMessage("异常请求");
		ResponsePack<JSONObject> responseEnv = new ResponsePack<JSONObject>(rae);
		return new ResponseEntity<>(responseEnv, HttpStatus.OK);
	}
	 /**
	 * 错误-404,403,402,401
	 */
	@RequestMapping(value = "/error_404", produces = { MediaType.APPLICATION_JSON_VALUE })
	public ResponseEntity<ResponsePack<JSONObject>> error_400(){
		RestApiError rae = new RestApiError();
		rae.setCode("404");
		rae.setMessage("找不到该请求");
		ResponsePack<JSONObject> responseEnv = new ResponsePack<JSONObject>(rae);
		return new ResponseEntity<>(responseEnv, HttpStatus.OK);
	}
}
